package cn.wonderland.service.impl;

import cn.wonderland.domain.Device;
import cn.wonderland.mapper.DeviceMapper;
import cn.wonderland.service.DeviceService;
import cn.wonderland.vo.DeviceBuildVo;
import cn.wonderland.vo.DeviceVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DeviceServiceImpl implements DeviceService {
    @Autowired
    private DeviceMapper deviceMapper;

    @Override
    public void addDevice(Device device) {
        deviceMapper.addDevice(device);
    }

    @Override
    public DeviceVo getDeviceInfoById(Integer id) {
        Device device = deviceMapper.getDeviceInfoById(id);
        DeviceVo deviceVo = new DeviceVo();
        deviceVo.setName(device.getName());
        deviceVo.setType(device.getType());
        deviceVo.setBuildId(device.getBuildId());
        deviceVo.setFloorId(device.getFloorId());
        return deviceVo;
    }

    @Override
    public List<DeviceBuildVo> getDeviceByBuildId(Integer id) {
        return deviceMapper.getDeviceByBuildId(id);
    }

    @Override
    public List<Device> getDeviceByType(Integer type) {
        return deviceMapper.getDeviceByType(type);
    }
}
